@LayoutSpec
class MyLayoutSpec {
@OnCreateLayout
static ComponentLayout onCreateLayout(ComponentContext c) {
return Column.create(c)
.alignItems(Align.STRETCH)
.child(Text.create(c)
.text("This is MY layout spec")
.withLayout()
.visibleHandler(MyLayoutSpec.onTitleVisible(c))
.invisibleHandler(MyLayoutSpec.onTitleInvisible(c)))
.focusedHandler(MyLayoutSpec.onComponentFocused(c, "someStringParam"))
.fullImpressionHandler(MyLayoutSpec.onComponentFullImpression(c)))
.build();
}
@OnEvent(VisibleEvent.class)
static void onTitleVisible(ComponentContext c) {
Log.d("VisibilityRanges", "The title entered the Visible Range");
}
@OnEvent(InvisibleEvent.class)
static void onTitleInvisible(ComponentContext c) {
Log.d("VisibilityRanges", "The title is no longer visible");
}
@OnEvent(FocusedVisibleEvent.class)
static void onComponentFocused(
ComponentContext c,
@Param String stringParam) {
Log.d(
"VisibilityRanges",
"The component is focused with param: " + contentString);
}
@OnEvent(FullImpressionVisibleEvent.class)
static void onComponentFullImpression(ComponentContext c) {
Log.d("VisibilityRanges", "The component has logged a full impression");
}
};